Release 10.1A: OpenEdge Development:
ProDataSets
Setting up an event handler for the OFF-END query event
Batching is supported by the
OFF-ENDevent on the query for thettOrdertemp-table. Whenever the client reaches the end of that query’s rows, as the user scrolls down through theOrderbrowse for example, the event allows your code to check whether there are more rows to retrieve.To set up this event, add this
SET-CALLBACK-PROCEDUREmethod to theLEAVEtrigger for theSalesRepfield, after getting the initial ProDataSet back from the support procedure:
Code the
OffEndOrderinternal procedure itself, also inPickOrderBatch.w. Like all event handlers, it receives the ProDataSet as anINPUTparameter by-reference, as shown:
This procedure needs to check to see whether all the
Ordershave been retrieved in the window procedure yet. TheLAST-BATCHattribute on thettOrderbuffer provides this information. If the last batch of rows hasn’t been returned, it passes the highestOrderNumvalue received so far to the samefetchOrderBatchroutine that brought the first batch of rows over to theSalesRepLEAVEtrigger. Whatever rows come back are appended to what is already in the local ProDataSet, as shown:
After disabling the Save button until the user has actually retrieved and made changes to an
Order’sOrderLines, the procedure simply executes aRETURN NO-APPLYstatement to cancel the default effects of theOFF-ENDevent on the query. In the background, Progress has automatically reopened theOrderBrowsequery on thettOrdertable, and repositioned it to the first new row returned. In this way, the rest of the client application doesn’t even know that the event occurred or that the end of the set of rows on the client was temporarily reached. For example:
If the
LAST-BATCHflag had already been set when the event occurred, none of the code would be executed and the procedure would return normally. Because there was noRETURN NO-APPLYstatement to cancel theOFF-END, theQUERY-OFF-ENDevent and any other related events such asOFF-ENDon the browse itself would occur.To see the effects of the new event handler, save both procedures and rerun the window. Tab through the
SalesRepfield and see the first batch of20Orders come up in theOrderbrowse. If you scroll down through thoseOrders, successive batches are transparently retrieved, added to the temp-table and its query, and therefore displayed in the browse. The browse’s ownOFF-ENDGUIevent never occurs until the last batch ofOrders is retrieved. (If you scroll patiently through all 4000+Orders, you’ll see the scrolling eventually end. If you defined anOFF-ENDtrigger for the browse, perhaps just to display a message, you’d see that the message doesn’t appear until you reach the end of all theOrders.) The same thing happens if the query’sOFF-ENDevent happens for any other reason, such as executing successiveGET-NEXTmethods on the query.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |